function setSkin(b){
	
	var a=$(document.body);
	a.attr("class",a.hasClass("navbar-fixed")?"navbar-fixed":"");
	if(b!="default"){
		a.addClass(b);
	}if(b=="skin-1"){
		$(".ace-nav > li.grey").addClass("dark");
	}else{
		$(".ace-nav > li.grey").removeClass("dark");
	}
	if(b=="skin-2"){
			$(".ace-nav > li").addClass("no-border margin-1");
			$(".ace-nav > li:not(:last-child)").addClass("white-pink")
			.find('> a > [class*="icon-"]').addClass("pink").end()
			.eq(0).find(".badge").addClass("badge-warning");
	}else{
			$(".ace-nav > li").removeClass("no-border").removeClass("margin-1");
			$(".ace-nav > li:not(:last-child)").removeClass("white-pink")
			.find('> a > [class*="icon-"]').removeClass("pink").end()
			.eq(0).find(".badge").removeClass("badge-warning");
	}
	if(b=="skin-3"){
		$(".ace-nav > li.grey").addClass("red").find(".badge").addClass("badge-yellow");
	}else{
		$(".ace-nav > li.grey").removeClass("red").find(".badge").removeClass("badge-yellow");
	}
}
jQuery(function($) {
	 var $sidebar = $('.sidebar').eq(0);
	$('#ace-settings-switch-menu').on('click', function(){
		if(this.checked) {
			if($('#sidebar').hasClass('h-sidebar')) return;
			$('#sidebar li').addClass('hover')
			.filter('.open').removeClass('open').find('> .submenu').css('display', 'none');
			//and remove .open items
			var $sidebar = $('#sidebar');
		    $sidebar.addClass("navbar-collapse h-sidebar");
			var $sidebar = $('#navbar');
		    $sidebar.addClass("navbar-collapse h-sidebar");
		}
		else {
			$('#sidebar li.hover').removeClass('hover');
			$('#sidebar').removeClass('navbar-collapse').removeClass('h-sidebar').addClass("sidebar");

			var compact = $('#ace-settings-compact');
			if( compact.length > 0 && compact.get(0).checked ) {
				compact.trigger('click');
			}
		}
	 })
	 $(document).on('settings.ace.top_menu' , function(ev, event_name, fixed) {
		if( event_name !== 'sidebar_fixed' ) return;
	
		var sidebar = $sidebar.get(0);
		var $window = $(window);
	
		//return if sidebar is not fixed or in mobile view mode
		var sidebar_vars = $sidebar.ace_sidebar('vars');
		if( !fixed || ( sidebar_vars['mobile_view'] || sidebar_vars['collapsible'] ) ) {
			$sidebar.removeClass('lower-highlight');
			//restore original, default marginTop
			sidebar.style.marginTop = '';
	
			$window.off('scroll.ace.top_menu')
			return;
		}
	
	
		 var done = false;
		 $window.on('scroll.ace.top_menu', function(e) {
	
			var scroll = $window.scrollTop();
			scroll = parseInt(scroll / 4);//move the menu up 1px for every 4px of document scrolling
			if (scroll > 17) scroll = 17;
	
	
			if (scroll > 16) {			
				if(!done) {
					$sidebar.addClass('lower-highlight');
					done = true;
				}
			}
			else {
				if(done) {
					$sidebar.removeClass('lower-highlight');
					done = false;
				}
			}
	
			//sidebar.style['marginTop'] = (17-scroll)+'px';
		 }).triggerHandler('scroll.ace.top_menu');
	
	 }).triggerHandler('settings.ace.top_menu', ['sidebar_fixed' , $sidebar.hasClass('sidebar-fixed')]);
	
	 $(window).on('resize.ace.top_menu', function() {
		$(document).triggerHandler('settings.ace.top_menu', ['sidebar_fixed' , $sidebar.hasClass('sidebar-fixed')]);
	 });
});